package com.kaifamiao.N0726;

import java.util.Random;
import java.util.Scanner;

public class Student {

    public String name;
    public double score;
    public int no;
    public void show(){
        System.out.println(name+score+no);
    }



    public static void main(String[] args) {
        Student[] w = new Student[5];
        for (int i = 0; i <= 4; i++) {
            w[i] = new Student();
            Scanner sc = new Scanner(System.in);
                System.out.println("请输入第" + (i + 1) + "个学生的名字");
                w[i].name = sc.next();
                System.out.println("请输入第" + (i + 1) + "个学生的学号");
                w[i].no = sc.nextInt();
                System.out.println("请输入第" + (i + 1) + "个学生的成绩");
                w[i].score = sc.nextDouble();
            }

        System.out.println("排序前:" );
        for(int p = 0 ;p<w.length;p++){

        }

        for (int n = 0; n < w.length - 1; n++) {
            for (int x = 0; x < w.length - n - 1; x++) {
                if (w[x].score > w[x + 1].score) {
                    Student y = w[x];
                    w[x] = w[x + 1];
                    w[x + 1] = y;
                }
            }
        }
        for (int x = 0; x < w.length; x++) {
            System.out.println("姓名:"+ w[x].name+"\t学号:"+w[x].no+ "\t成绩:"+w[x].score);
        }
    }
}
